﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Model;
using BLL;
using DAL;
using IDAL;

/***************************
 * 数据访问层
 * 字典管理
 * Author：JXL
 ***************************/ 
namespace EstateService.Controllers
{
    public class DictionaryController : ApiController
    {
        Factory<IDictionary, DictionaryDAL> bll = new Factory<IDictionary, DictionaryDAL>();
       
        
        // GET api/dictionary
        /// <summary>
        /// 获取字典列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("getdictionary")]
        
       
        public List<Dictionary> getdictionary()
        {

            return bll.bll().getDictionary();
        }

        // GET api/dictionary/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/dictionary
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public int Post([FromBody]Dictionary value)
        {
          return  bll.bll().insert<Dictionary>(value);
        }

        // PUT api/dictionary/5
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public int Put(int id, [FromBody]Dictionary value)
        {
            return bll.bll().update<Dictionary>(value, id.ToString());
        }

        // DELETE api/dictionary/5
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int id)
        {
            return bll.bll().delete(id.ToString());
        }

        //public string Options()
        //{

        //    return null; // HTTP 200 response with empty body

        //} 
    }
}
